<html>
<head>
    <meta charset="utf-8">
    <title>编辑轮播图</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="shortcut icon" href="__PUBLIC__/Admin/images/favicon1.ico">


    <!--Basic Styles-->
    <link href="__PUBLIC__/Admin/style/bootstrap.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/style/font-awesome.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__PUBLIC__/Admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/Admin/style/demo.css" rel="stylesheet">
    <link href="__PUBLIC__/Admin/style/typicons.css" rel="stylesheet">
    <link href="__PUBLIC__/Tools/um/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">


    <script src="__PUBLIC__/Admin/style/jquery_002.js"></script>
    <script src="__PUBLIC__/Admin/style/jquery.js"></script>
    <script src="__PUBLIC__/Admin/style/bootstrap.js"></script>


    <!--<script type="text/javascript" src="__PUBLIC__/Tools/um/third-party/jquery.min.js"></script>-->
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/Tools/um/umeditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/Tools/um/umeditor.min.js"></script>
    <!--<script type="text/javascript" src="__PUBLIC__/Tools/um/lang/zh-cn/zh-cn.js"></script>-->
   
</head>
<body>
<!-- 头部 -->
<include file="Common/header"/>
<!-- /头部 -->
<div class="main-container container-fluid">
    <div class="page-container">
        <!-- Page 侧边栏 -->
        <include file="Common/sidebar"/>
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                           <a href="__MODULE__/Banners/index">
                               轮播图
                           </a>
                        </li>
                        <li class="active">
                            编辑轮播图
                        </li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header bordered-bottom bordered-blue">
                <span class="widget-caption">编辑轮播图</span>
            </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form" action="" method="post" enctype ="multipart/form-data" id="bannersAdd">
                        <input type="hidden" name="id" value="{$banner.id}">
                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label no-padding-right">标题</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="title" placeholder="" name="title"  type="text" value="{$banner.title}">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>

                        <div class="form-group">
                            <label for="description" class="col-sm-2 control-label no-padding-right">描述</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="description" placeholder="" name="description"  type="text" value="{$banner.description}">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>


                        <div class="form-group">
                            <label for="title" class="col-sm-2 control-label no-padding-right">图片大小:</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="size" placeholder="(手机端轮播图大小)格式:宽x高" name="size"  type="text" value="{$banner.size}">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">
                                是否显示
                            </label>
                            <div class="col-xs-4">
                                <label class="radio-online">
                                    <input type="radio" name="is_show"  value="1" style="opacity: 1; position:relative; left:0" <if condition=" $banner.is_show eq 1">checked</if> /> 是
                                </label>
                                <label class="radio-online">
                                    <input type="radio" name="is_show"  value="0" style="opacity: 1; position:relative; left:0" <if condition=" $banner.is_show eq 0">checked</if> /> 否
                                </label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">
                                图片
                            </label>
                            &nbsp;&nbsp;
                            <div class="col-xs-8">
                                <div class="form-group">
                                    <!--<input type="file" id="image" name="image">-->
                                    <link href="__PUBLIC__/Tools/ajaxImageUpload/css/upload.css" type="text/css" rel="stylesheet"/>
                                    <div class="upload-box" style="margin-top:0;">
                                        <style>
                                           .image-box section{
                                               width:150px;
                                               height:150px;
                                           }
                                        </style>
                                        <div class="image-box clear">
                                            <section class="upload-section" style="height:auto;">
                                                <div class="upload-btn"></div>
                                                <input type="file" name="upload_image" id="upload-input"/>
                                            </section>
                                        </div>
                                    </div>
                                    <input type="hidden" name="image" value="{$banner.origin_image}">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="sort" class="col-sm-2 control-label no-padding-right">排序</label>
                            <div class="col-sm-6">
                                <input class="form-control" id="sort" placeholder="排序(数字),默认排序越大小越靠前" name="sort"  type="text" value="{$banner.sort}">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">
                                    保存信息
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>
</body>
</html>
<script src="__PUBLIC__/Admin/style/beyond.js"></script>
<script src="__PUBLIC__/Admin/layer/layer.js"></script>

<script src="__PUBLIC__/Tools/ajaxImageUpload/js/upload.js"></script>
<script>

    $("#upload-input").ajaxImageUpload({
        url: "__MODULE__/File/upload", //上传的服务器地址
        //data: { image:'liang' },
        maxNum: 1, //允许上传图片数量
        zoom: false, //允许上传图片点击放大
        allowType: ["gif", "jpeg", "jpg", "bmp",'png'], //允许上传图片的类型
        maxSize :1, //允许上传图片的最大尺寸，单位M
        before: function () {
            //alert('上传前回调函数');
        },
        success:function(data){
            $('input[name=image]').attr('value', data.src);
        },
        error:function (e) {
             console.log(e);
        }
    });
    
</script>

<script>
    $(document).ready(function () {
        $('#bannersAdd').submit(function (event) {
            var id = $('input[name=id]').val();
            var title = $('input[name=title]').val();
            var description = $('input[name=description]').val();
            var is_show = $('input[name=is_show]:checked').val();
            var image = $('input[name=image]').val();
            var sort = $('input[name=sort]').val();
            var size = $('input[name=size]').val();

            $.post('__MODULE__/Banners/modify',{id:id,title:title,description:description,is_show:is_show,image:image,sort:sort,size:size}, function(result){
                if (result === 'true') {
                        window.location.href = '__MODULE__/Banners/index';
                    } else {
                    layer.open({
                        type: 1,
                        offset:['100px', '500px'],
                        area: ['300px', '300px'],
                        shadeClose: true, //点击遮罩关闭
                        content: '\<\div style="padding:20px;">'+result+'\<\/div>'
                    });
                }
            });
            event.preventDefault();
            return false;
        });
     });
</script>
